{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "fyQuYILRn7RS"
   },
   "outputs": [],
   "source": [
    "# this is the dataset to use\n",
    "# https://github.com/ofrendo/WebDataIntegration/blob/7db877abadd2be94d5373f5f47c8ccd1d179bea6/data/goldstandard/forbes_freebase_goldstandard_train.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 212
    },
    "colab_type": "code",
    "id": "8WYsEdpDPKU4",
    "outputId": "c8d29ad4-69ee-4fac-f277-152e4a08afec"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--2020-10-11 23:37:06--  https://raw.githubusercontent.com/ofrendo/WebDataIntegration/7db877abadd2be94d5373f5f47c8ccd1d179bea6/data/goldstandard/forbes_freebase_goldstandard_train.csv\n",
      "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.16.133\n",
      "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.16.133|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 7324 (7.2K) [text/plain]\n",
      "Saving to: ‘forbes_freebase_goldstandard_train.csv’\n",
      "\n",
      "forbes_freebase_gol 100%[===================>]   7.15K  --.-KB/s    in 0.009s  \n",
      "\n",
      "2020-10-11 23:37:07 (782 KB/s) - ‘forbes_freebase_goldstandard_train.csv’ saved [7324/7324]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!wget https://raw.githubusercontent.com/ofrendo/WebDataIntegration/7db877abadd2be94d5373f5f47c8ccd1d179bea6/data/goldstandard/forbes_freebase_goldstandard_train.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "WI67lN68POnO"
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "data = pd.read_csv('forbes_freebase_goldstandard_train.csv', names=['string1', 'string2', 'matched'])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "uO_s51GFQHy1"
   },
   "source": [
    "loading training data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 212
    },
    "colab_type": "code",
    "id": "aXGqoY_9QBj9",
    "outputId": "d35bd9ff-e7ca-4f9a-e6c8-84b076304304"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--2020-10-11 23:54:11--  https://raw.githubusercontent.com/ofrendo/WebDataIntegration/7db877abadd2be94d5373f5f47c8ccd1d179bea6/data/goldstandard/forbes_freebase_goldstandard_test.csv\n",
      "Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.16.133\n",
      "Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.16.133|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 976 [text/plain]\n",
      "Saving to: ‘forbes_freebase_goldstandard_test.csv.1’\n",
      "\n",
      "forbes_freebase_gol 100%[===================>]     976  --.-KB/s    in 0s      \n",
      "\n",
      "2020-10-11 23:54:12 (20.2 MB/s) - ‘forbes_freebase_goldstandard_test.csv.1’ saved [976/976]\n",
      "\n"
     ]
    }
   ],
   "source": [
    "!wget https://raw.githubusercontent.com/ofrendo/WebDataIntegration/7db877abadd2be94d5373f5f47c8ccd1d179bea6/data/goldstandard/forbes_freebase_goldstandard_test.csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 197
    },
    "colab_type": "code",
    "id": "s1B_H9B0PVVh",
    "outputId": "1cc7d96a-3614-427c-eb95-2de050520b01"
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>string1</th>\n",
       "      <th>string2</th>\n",
       "      <th>matched</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>General Electric</td>\n",
       "      <td>General Electric</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Wells Fargo</td>\n",
       "      <td>Wells Fargo</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Bank of China</td>\n",
       "      <td>Industrial and Commercial Bank of China (Asia)</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>PetroChina</td>\n",
       "      <td>PetroChina</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Apple</td>\n",
       "      <td>Apple Inc.</td>\n",
       "      <td>True</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            string1                                         string2  matched\n",
       "0  General Electric                                General Electric     True\n",
       "1       Wells Fargo                                     Wells Fargo     True\n",
       "2     Bank of China  Industrial and Commercial Bank of China (Asia)     True\n",
       "3        PetroChina                                      PetroChina     True\n",
       "4             Apple                                      Apple Inc.     True"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "id": "AaWETqtZPach",
    "outputId": "827e61ef-f4bd-4ae1-d64f-850b5f5a3ddd"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "212"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 212
    },
    "colab_type": "code",
    "id": "JHkt36DhwkUt",
    "outputId": "5b44ed47-4a50-403b-fb66-a05a28336ee9"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Collecting python-Levenshtein\n",
      "  Downloading python-Levenshtein-0.12.0.tar.gz (48 kB)\n",
      "\u001b[K     |████████████████████████████████| 48 kB 2.0 MB/s eta 0:00:011\n",
      "\u001b[?25hRequirement already satisfied: setuptools in /Users/ben/anaconda3/lib/python3.6/site-packages (from python-Levenshtein) (49.6.0.post20200814)\n",
      "Building wheels for collected packages: python-Levenshtein\n",
      "  Building wheel for python-Levenshtein (setup.py) ... \u001b[?25ldone\n",
      "\u001b[?25h  Created wheel for python-Levenshtein: filename=python_Levenshtein-0.12.0-cp36-cp36m-macosx_10_7_x86_64.whl size=80048 sha256=63813405d0de8ace271d0d15f41461ddea38df8cf475b3390e9bed0ee68ba08f\n",
      "  Stored in directory: /Users/ben/Library/Caches/pip/wheels/79/c3/a1/cbdd8b154234b3e571d121b65be7d53354cc77e223e8f271c8\n",
      "Successfully built python-Levenshtein\n",
      "Installing collected packages: python-Levenshtein\n",
      "Successfully installed python-Levenshtein-0.12.0\n"
     ]
    }
   ],
   "source": [
    "!pip install python-Levenshtein"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "211FA9izvDG2"
   },
   "outputs": [],
   "source": [
    "import joblib\n",
    "import os\n",
    "from multiprocessing import Pool\n",
    "import re\n",
    "from difflib import SequenceMatcher  # for longest common substring\n",
    "from functools import partial\n",
    "from operator import itemgetter\n",
    "import Levenshtein  # levenstein/edit distance; docs here: https://rawgit.com/ztane/python-Levenshtein/master/docs/Levenshtein.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "9Sif6SdJpDNb"
   },
   "outputs": [],
   "source": [
    "def clean_string(string):\n",
    "    '''We will use this functions to remove special characters etc before \n",
    "    any string distance calculation.\n",
    "    '''\n",
    "    return ''.join(map(lambda x: x.lower() if str.isalnum(x) else ' ', string)).strip()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "FBIyzgvhvI1z"
   },
   "source": [
    "I think it's useful to make a distinction here\n",
    "- distance functions between two strings\n",
    "- string featurization\n",
    "\n",
    "The string distances we can use to establish a baseline performance. But with small changes we can make them string featurization functions and use them in classifier functions in a machine learning approach. However, let us get first to string distances.\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "8logLPvLve7y"
   },
   "outputs": [],
   "source": [
    "def levenstein_distance(s1_, s2_):\n",
    "    s1, s2 = clean_string(s1_), clean_string(s2_)\n",
    "    len_s1, len_s2 = len(s1), len(s2)\n",
    "    return Levenshtein.distance(\n",
    "        s1, s2\n",
    "    ) / max([len_s1, len_s2])\n",
    "\n",
    "def jaro_winkler_distance(s1_, s2_):\n",
    "    s1, s2 = clean_string(s1_), clean_string(s2_)\n",
    "    return Levenshtein.jaro_winkler(s1, s2)\n",
    "\n",
    "def common_substring_distance(s1_, s2_):\n",
    "    s1, s2 = clean_string(s1_), clean_string(s2_)\n",
    "    len_s1, len_s2 = len(s1), len(s2)\n",
    "    match = SequenceMatcher(\n",
    "        None, s1, s2\n",
    "    ).find_longest_match(0, len_s1, 0, len_s2)\n",
    "    len_s1, len_s2 = len(s1), len(s2)\n",
    "    norm = max([len_s1, len_s2])\n",
    "    return 1 - min([1, match.size / norm])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AUC for levenstein_distance: 0.9508904955034385\n",
      "AUC for jaro_winkler_distance: 0.052900722976547354\n",
      "AUC for common_substring_distance: 0.9560042320578381\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from sklearn.metrics import roc_auc_score\n",
    "\n",
    "dists = np.zeros(shape=(len(data), 3))\n",
    "for algo_i, algo in enumerate(\n",
    "    [levenstein_distance, jaro_winkler_distance, common_substring_distance]\n",
    "):\n",
    "    for i, string_pair in data.iterrows():\n",
    "        dists[i, algo_i] = algo(string_pair['string1'], string_pair['string2'])\n",
    "        \n",
    "    print('AUC for {}: {}'.format(\n",
    "        algo.__name__, \n",
    "        roc_auc_score(data['matched'].astype(float), 1 - dists[:, algo_i])\n",
    "    ))\n",
    "#AUC for levenstein_distance: 0.9508904955034385\n",
    "#AUC for jaro_winkler_distance: 0.9470992770234525\n",
    "#AUC for common_substring_distance: 0.9560042320578381"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "LBO1cvFZn6-Z"
   },
   "outputs": [],
   "source": [
    "# we can use these string functions for fuzzy string match\n",
    "# some matches are not very good, so we should make sure, we have thresholds.\n",
    "\n",
    "pool = Pool(50)\n",
    "\n",
    "def fuzzy_string_search(\n",
    "    s1, string_list,\n",
    "     string_compare,\n",
    "      threshold=lambda sim: sim>0.7\n",
    "    ):\n",
    "    '''Search through a list of strings using a string_comparison function\n",
    "    in order to find the best match.\n",
    "\n",
    "    Parameters:\n",
    "    - s1: string to search for\n",
    "    - string_list: list of strings\n",
    "    - string_compare: string comparison function to return a similarity or a \n",
    "      distance.\n",
    "    - threshold: cut-off function to decide if returning the best match or\n",
    "      nothing at all. This threshold function has to take into account if we\n",
    "      are using a string similarity or a string distance.\n",
    "\n",
    "    Return the best matching string if threshold reached.\n",
    "    Otherwise return None.\n",
    "\n",
    "    Example:\n",
    "    >> company_list = [\n",
    "        'Blackrock',\n",
    "        'Credit Suisse',\n",
    "        'Goldman Sachs',\n",
    "        'Bank of America/Meryll Lynch',\n",
    "        'Morgan Stanley',\n",
    "        'LEK',\n",
    "        'JP Morgan',\n",
    "        'Nomura',\n",
    "        'BNP Paribas',\n",
    "        'WPP',\n",
    "        'Rothschild',\n",
    "        'Allianz',\n",
    "    ]\n",
    "    >> fuzzy_string_search(\n",
    "      'SAP',\n",
    "      company_list,\n",
    "      jaro_winkler_distance,\n",
    "      threshold=lambda dist: dist<0.7\n",
    "    )\n",
    "    '''\n",
    "    string_match = partial(string_compare, s2_=s1)\n",
    "    comparisons = pool.map(string_match, string_list)\n",
    "    index, element = max(enumerate(comparisons), key=itemgetter(1))\n",
    "    #print(f\"match {string_list[index]} with score {element}\")\n",
    "    if threshold(element):\n",
    "        return string_list[index]\n",
    "    else:\n",
    "        return None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "id": "HbwJKVc3yZrJ",
    "outputId": "eaee3474-71a2-4c8b-d62a-b79d73c8f27c"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'WPP'"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "company_list = [\n",
    "        'Blackrock',\n",
    "        'Credit Suisse',\n",
    "        'Goldman Sachs',\n",
    "        'Bank of America/Meryll Lynch',\n",
    "        'Morgan Stanley',\n",
    "        'LEK',\n",
    "        'JP Morgan',\n",
    "        'Nomura',\n",
    "        'BNP Paribas',\n",
    "        'WPP',\n",
    "        'Rothschild',\n",
    "        'Allianz',\n",
    "    ]\n",
    "fuzzy_string_search(\n",
    "      'SAP',\n",
    "      company_list,\n",
    "      jaro_winkler_distance,\n",
    "      threshold=lambda dist: dist<0.7\n",
    "    )\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Zvf4CavVtWmT"
   },
   "outputs": [],
   "source": [
    "# We can also use featurizations of strings, for example using sklearn\n",
    "# inbuilt functionality such as CountVectorizers or TfidfVectorizer.\n",
    "\n",
    "\n",
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "# the CountVectorizer counts the occurences of features. These features\n",
    "# can be composed of characters or words; we are interested in character-\n",
    "# based features. We clean the strings as before and we take ngrams.\n",
    "# Also try TfidfVectorizer for a baseline performance\n",
    "\n",
    "# We can also use featurizations of strings, for example using sklearn\n",
    "# inbuilt functionality such as CountVectorizers or TfidfVectorizer.\n",
    "\n",
    "\n",
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "# the CountVectorizer counts the occurences of features. These features\n",
    "# can be composed of characters or words; we are interested in character-\n",
    "# based features. We clean the strings as before and we take ngrams.\n",
    "# Also try TfidfVectorizer for a baseline performance\n",
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "\n",
    "# We clean the strings as before and we take ngrams.\n",
    "ngram_featurizer = CountVectorizer(\n",
    "    min_df=1,\n",
    "    analyzer='char',\n",
    "    ngram_range=(1, 1), # this is the range of ngrams that are to be extracted!\n",
    "    preprocessor=clean_string\n",
    ")\n",
    "company_space = ngram_featurizer.fit_transform(\n",
    "    np.concatenate(\n",
    "        [data['string1'], data['string2']],\n",
    "        axis=0\n",
    "    )\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 52
    },
    "colab_type": "code",
    "id": "68Kdi7sWyej3",
    "outputId": "5acba677-1112-4b81-8f7e-b7ab87eeeb44"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<426x41 sparse matrix of type '<class 'numpy.int64'>'\n",
       "\twith 4003 stored elements in Compressed Sparse Row format>"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "company_space"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9298183741844471"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "string1cv = ngram_featurizer.transform(data['string1'])\n",
    "string2cv = ngram_featurizer.transform(data['string2'])\n",
    "\n",
    "def norm(string1cv):\n",
    "    return string1cv / string1cv.sum(axis=1)\n",
    "\n",
    "similarities = 1 - np.sum(np.abs(norm(string1cv) - norm(string2cv)), axis=1) / 2\n",
    "roc_auc_score(data['matched'].astype(float), similarities)\n",
    "#0.9298183741844471\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "7eT2hm7z2D2Z"
   },
   "outputs": [],
   "source": [
    "# Some alternative way to featurize strings. These can be used in similar ways \n",
    "# to the CountVectorizer really. Apply these as a preprocessor to a classifier\n",
    "# and check the performance in distinguishing between match and no-match.\n",
    "\n",
    "def editops_featurizer(s1_, s2_):\n",
    "    '''Counts the replace, insert and delete operations between two strings\n",
    "    and normalizes these by maximum string length.\n",
    "\n",
    "    This featurization could be interesting to find out which operation is\n",
    "    most useful.\n",
    "    '''\n",
    "    s1, s2 = clean_string(s1_), clean_string(s2_)\n",
    "    len_s1, len_s2 = len(s1), len(s2)\n",
    "    ops = Levenshtein.editops(\n",
    "        s1, s2\n",
    "    )\n",
    "    index_dict = {'insert': 0, 'replace': 1, 'delete': 2}\n",
    "    features = np.zeros((3))\n",
    "    for op in edit_ops:\n",
    "        features[index_dict[op[0]]] += 1\n",
    "    features / max([len_s1, len_s2])  \n",
    "    return features\n",
    "\n",
    "def common_substring_featurizer(s1_, s2_):\n",
    "    '''Here we extract 1. the normalized length of the common substring\n",
    "    and whether the common substring matches 2. the beginning or\n",
    "    3. the end of a word.\n",
    "    '''\n",
    "    s1, s2 = clean_string(s1_), clean_string(s2_)\n",
    "    len_s1, len_s2 = len(s1), len(s2)\n",
    "    longer_string = s1 if len_s1 > len_s2 else s2\n",
    "    norm = max([len_s1, len_s2])    \n",
    "    match = SequenceMatcher(None, s1, s2).find_longest_match(0, len_s1, 0, len_s2)\n",
    "    substring = s1[match.a: match.a + match.size]\n",
    "    \n",
    "    m1 = re.search(\n",
    "        '(?:^|\\s|[a-z])' + substring,\n",
    "        longer_string\n",
    "    )\n",
    "    m2 = re.search(\n",
    "        substring + '(?:[a-z]|\\s|$)',\n",
    "        longer_string\n",
    "    )\n",
    "    return min([1, match.size / norm]), m1 is not None, m2 is not None"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 705
    },
    "colab_type": "code",
    "id": "e0T2OgbZp8jt",
    "outputId": "f3baa8c6-7d14-419b-fbd4-b7c19af7288f"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Model: \"sequential_4\"\n",
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
      "dense_4 (Dense)              (None, 50)                2100      \n",
      "=================================================================\n",
      "Total params: 2,100\n",
      "Trainable params: 2,100\n",
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n",
      "2 models to be trained against each other\n",
      "Model: \"model_4\"\n",
      "__________________________________________________________________________________________________\n",
      "Layer (type)                    Output Shape         Param #     Connected to                     \n",
      "==================================================================================================\n",
      "input_9 (InputLayer)            [(None, 41)]         0                                            \n",
      "__________________________________________________________________________________________________\n",
      "input_10 (InputLayer)           [(None, 41)]         0                                            \n",
      "__________________________________________________________________________________________________\n",
      "sequential_4 (Sequential)       (None, 50)           2100        input_9[0][0]                    \n",
      "                                                                 input_10[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "lambda_4 (Lambda)               (None, 1)            0           sequential_4[1][0]               \n",
      "                                                                 sequential_4[2][0]               \n",
      "==================================================================================================\n",
      "Total params: 2,100\n",
      "Trainable params: 2,100\n",
      "Non-trainable params: 0\n",
      "__________________________________________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "# siamese network dimensionality reduction\n",
    "from tensorflow.keras.models import Sequential,Model\n",
    "from tensorflow.keras.layers import Dense, Lambda, Input\n",
    "import tensorflow as tf\n",
    "from tensorflow.keras import backend as K\n",
    "\n",
    "\n",
    "\n",
    "def create_string_featurization_model(feature_dimensionality, output_dim=50):\n",
    "    '''\n",
    "    Use for string featurization in combination with siamese models.\n",
    "    Just a non-linear projection as a way of reducing the feature dimensionality\n",
    "    in a meaningful way.\n",
    "\n",
    "    Parameters:\n",
    "        feature_dimensionality - number of features coming from the vectorizer\n",
    "          or string featurization function\n",
    "        output_dim - dimensions of the embedding/projection that we are trying\n",
    "          to create\n",
    "    '''\n",
    "    preprocessing_model = Sequential()\n",
    "    preprocessing_model.add(\n",
    "        Dense(output_dim, activation='selu', input_dim=feature_dimensionality)\n",
    "    )\n",
    "    preprocessing_model.summary()\n",
    "    return preprocessing_model\n",
    "\n",
    "def create_siamese_model(preprocessing_models, #initial_bias =\n",
    "                          input_shapes=(10,)):\n",
    "    def euclidean_distance(vects):\n",
    "        x, y = vects\n",
    "        x = K.l2_normalize(x, axis=-1)\n",
    "        y = K.l2_normalize(y, axis=-1)\n",
    "        sum_square = K.sum(K.square(x - y), axis=1, keepdims=True)\n",
    "        return K.sqrt(K.maximum(sum_square, K.epsilon()))\n",
    "    \n",
    "    if not isinstance(preprocessing_models, (list, tuple)):\n",
    "        raise ValueError('preprocessing models needs to be a list or tuple of models')\n",
    "\n",
    "    print('{} models to be trained against each other'.format(len(preprocessing_models)))\n",
    "    if not isinstance(input_shapes, list):\n",
    "        input_shapes = [input_shapes] * len(preprocessing_models)\n",
    "    \n",
    "    inputs = []\n",
    "    intermediate_layers = []\n",
    "    for preprocessing_model, input_shape in zip(preprocessing_models, input_shapes):\n",
    "        inputs.append(Input(shape=input_shape))\n",
    "        intermediate_layers.append(preprocessing_model(inputs[-1]))\n",
    "\n",
    "    layer_diffs = []\n",
    "    for i in range(len(intermediate_layers)-1):        \n",
    "        layer_diffs.append(\n",
    "            Lambda(euclidean_distance)([intermediate_layers[i], intermediate_layers[i+1]])\n",
    "        )    \n",
    "    siamese_model = Model(inputs=inputs, outputs=layer_diffs)\n",
    "    siamese_model.summary()\n",
    "    return siamese_model\n",
    "\n",
    "def compile_model(model):\n",
    "    model.compile(\n",
    "        optimizer='rmsprop',\n",
    "        loss='mse',\n",
    "        metrics=[\n",
    "            #'accuracy',\n",
    "            #tf.keras.metrics.FalseNegatives(name='fn'), \n",
    "            #tf.keras.metrics.Precision(name='precision'),\n",
    "            tf.keras.metrics.Recall(name='recall'),\n",
    "            #tf.keras.metrics.AUC(name='auc'),\n",
    "        ]\n",
    "    )\n",
    "\n",
    "# use like this:\n",
    "feature_dims = len(ngram_featurizer.get_feature_names())\n",
    "string_featurization_model = create_string_featurization_model(feature_dims, output_dim=50)\n",
    "\n",
    "siamese_model = create_siamese_model(\n",
    "    preprocessing_models=[string_featurization_model, string_featurization_model],\n",
    "    input_shapes=[(feature_dims,), (feature_dims,)],\n",
    ")\n",
    "compile_model(siamese_model)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 316
    },
    "colab_type": "code",
    "id": "t6lo6MIN9QwY",
    "outputId": "be86cd9a-e17a-4d75-97c8-a867335fbc24"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9298183741844471"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "from sklearn.metrics import roc_auc_score\n",
    "\n",
    "string1cv = ngram_featurizer.transform(data['string1'])\n",
    "string2cv = ngram_featurizer.transform(data['string2'])\n",
    "\n",
    "def norm(string1cv):\n",
    "    return string1cv / string1cv.sum(axis=1)\n",
    "\n",
    "similarities = 1 - np.sum(np.abs(norm(string1cv) - norm(string2cv)), axis=1) / 2\n",
    "roc_auc_score(data['matched'].astype(float), similarities)\n",
    "#0.9298183741844471"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 213 samples\n",
      "Epoch 1/1000\n",
      "213/213 [==============================] - 0s 2ms/sample - loss: 0.1020 - recall: 0.9439\n",
      "Epoch 2/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0950 - recall: 0.9439\n",
      "Epoch 3/1000\n",
      "213/213 [==============================] - 0s 316us/sample - loss: 0.0914 - recall: 0.9439\n",
      "Epoch 4/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0882 - recall: 0.9439\n",
      "Epoch 5/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0856 - recall: 0.9439\n",
      "Epoch 6/1000\n",
      "213/213 [==============================] - 0s 205us/sample - loss: 0.0827 - recall: 0.9533\n",
      "Epoch 7/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0802 - recall: 0.9533\n",
      "Epoch 8/1000\n",
      "213/213 [==============================] - 0s 245us/sample - loss: 0.0778 - recall: 0.9533\n",
      "Epoch 9/1000\n",
      "213/213 [==============================] - 0s 196us/sample - loss: 0.0756 - recall: 0.9533\n",
      "Epoch 10/1000\n",
      "213/213 [==============================] - 0s 228us/sample - loss: 0.0734 - recall: 0.9533\n",
      "Epoch 11/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0713 - recall: 0.9626\n",
      "Epoch 12/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0695 - recall: 0.9626\n",
      "Epoch 13/1000\n",
      "213/213 [==============================] - 0s 183us/sample - loss: 0.0677 - recall: 0.9626\n",
      "Epoch 14/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0660 - recall: 0.9626\n",
      "Epoch 15/1000\n",
      "213/213 [==============================] - ETA: 0s - loss: 0.0250 - recall: 1.00 - 0s 176us/sample - loss: 0.0645 - recall: 0.9626\n",
      "Epoch 16/1000\n",
      "213/213 [==============================] - 0s 192us/sample - loss: 0.0627 - recall: 0.9626\n",
      "Epoch 17/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0613 - recall: 0.9626\n",
      "Epoch 18/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0597 - recall: 0.9626\n",
      "Epoch 19/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0585 - recall: 0.9626\n",
      "Epoch 20/1000\n",
      "213/213 [==============================] - 0s 181us/sample - loss: 0.0572 - recall: 0.9626\n",
      "Epoch 21/1000\n",
      "213/213 [==============================] - 0s 213us/sample - loss: 0.0561 - recall: 0.9626\n",
      "Epoch 22/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0549 - recall: 0.9626\n",
      "Epoch 23/1000\n",
      "213/213 [==============================] - 0s 166us/sample - loss: 0.0537 - recall: 0.9626\n",
      "Epoch 24/1000\n",
      "213/213 [==============================] - 0s 204us/sample - loss: 0.0527 - recall: 0.9626\n",
      "Epoch 25/1000\n",
      "213/213 [==============================] - 0s 201us/sample - loss: 0.0517 - recall: 0.9626\n",
      "Epoch 26/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0508 - recall: 0.9626\n",
      "Epoch 27/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0499 - recall: 0.9626\n",
      "Epoch 28/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0491 - recall: 0.9626\n",
      "Epoch 29/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0482 - recall: 0.9626\n",
      "Epoch 30/1000\n",
      "213/213 [==============================] - 0s 175us/sample - loss: 0.0474 - recall: 0.9626\n",
      "Epoch 31/1000\n",
      "213/213 [==============================] - 0s 201us/sample - loss: 0.0467 - recall: 0.9626\n",
      "Epoch 32/1000\n",
      "213/213 [==============================] - 0s 207us/sample - loss: 0.0460 - recall: 0.9626\n",
      "Epoch 33/1000\n",
      "213/213 [==============================] - 0s 181us/sample - loss: 0.0454 - recall: 0.9626\n",
      "Epoch 34/1000\n",
      "213/213 [==============================] - 0s 179us/sample - loss: 0.0446 - recall: 0.9626\n",
      "Epoch 35/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0440 - recall: 0.9626\n",
      "Epoch 36/1000\n",
      "213/213 [==============================] - 0s 173us/sample - loss: 0.0434 - recall: 0.9626\n",
      "Epoch 37/1000\n",
      "213/213 [==============================] - 0s 180us/sample - loss: 0.0428 - recall: 0.9626\n",
      "Epoch 38/1000\n",
      "213/213 [==============================] - 0s 124us/sample - loss: 0.0422 - recall: 0.9626\n",
      "Epoch 39/1000\n",
      "213/213 [==============================] - 0s 238us/sample - loss: 0.0416 - recall: 0.9626\n",
      "Epoch 40/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0410 - recall: 0.9626\n",
      "Epoch 41/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0405 - recall: 0.9626\n",
      "Epoch 42/1000\n",
      "213/213 [==============================] - 0s 189us/sample - loss: 0.0401 - recall: 0.9626\n",
      "Epoch 43/1000\n",
      "213/213 [==============================] - 0s 208us/sample - loss: 0.0396 - recall: 0.9626\n",
      "Epoch 44/1000\n",
      "213/213 [==============================] - 0s 162us/sample - loss: 0.0392 - recall: 0.9626\n",
      "Epoch 45/1000\n",
      "213/213 [==============================] - 0s 173us/sample - loss: 0.0388 - recall: 0.9626\n",
      "Epoch 46/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0383 - recall: 0.9626\n",
      "Epoch 47/1000\n",
      "213/213 [==============================] - 0s 185us/sample - loss: 0.0379 - recall: 0.9626\n",
      "Epoch 48/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0375 - recall: 0.9626\n",
      "Epoch 49/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0371 - recall: 0.9626\n",
      "Epoch 50/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0368 - recall: 0.9720\n",
      "Epoch 51/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0364 - recall: 0.9720\n",
      "Epoch 52/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0361 - recall: 0.9720\n",
      "Epoch 53/1000\n",
      "213/213 [==============================] - 0s 220us/sample - loss: 0.0358 - recall: 0.9720\n",
      "Epoch 54/1000\n",
      "213/213 [==============================] - 0s 144us/sample - loss: 0.0354 - recall: 0.9720\n",
      "Epoch 55/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0351 - recall: 0.9720\n",
      "Epoch 56/1000\n",
      "213/213 [==============================] - 0s 197us/sample - loss: 0.0349 - recall: 0.9720\n",
      "Epoch 57/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0345 - recall: 0.9720\n",
      "Epoch 58/1000\n",
      "213/213 [==============================] - 0s 261us/sample - loss: 0.0342 - recall: 0.9720\n",
      "Epoch 59/1000\n",
      "213/213 [==============================] - 0s 130us/sample - loss: 0.0339 - recall: 0.9720\n",
      "Epoch 60/1000\n",
      "213/213 [==============================] - 0s 183us/sample - loss: 0.0337 - recall: 0.9720\n",
      "Epoch 61/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0335 - recall: 0.9720\n",
      "Epoch 62/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0331 - recall: 0.9720\n",
      "Epoch 63/1000\n",
      "213/213 [==============================] - 0s 127us/sample - loss: 0.0330 - recall: 0.9720\n",
      "Epoch 64/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0328 - recall: 0.9720\n",
      "Epoch 65/1000\n",
      "213/213 [==============================] - 0s 172us/sample - loss: 0.0325 - recall: 0.9720\n",
      "Epoch 66/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0323 - recall: 0.9720\n",
      "Epoch 67/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0321 - recall: 0.9720\n",
      "Epoch 68/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0319 - recall: 0.9720\n",
      "Epoch 69/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0316 - recall: 0.9720\n",
      "Epoch 70/1000\n",
      "213/213 [==============================] - 0s 249us/sample - loss: 0.0314 - recall: 0.9720\n",
      "Epoch 71/1000\n",
      "213/213 [==============================] - 0s 155us/sample - loss: 0.0313 - recall: 0.9720\n",
      "Epoch 72/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0311 - recall: 0.9720\n",
      "Epoch 73/1000\n",
      "213/213 [==============================] - 0s 176us/sample - loss: 0.0309 - recall: 0.9720\n",
      "Epoch 74/1000\n",
      "213/213 [==============================] - 0s 187us/sample - loss: 0.0307 - recall: 0.9720\n",
      "Epoch 75/1000\n",
      "213/213 [==============================] - 0s 155us/sample - loss: 0.0305 - recall: 0.9720\n",
      "Epoch 76/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0304 - recall: 0.9720\n",
      "Epoch 77/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0302 - recall: 0.9720\n",
      "Epoch 78/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0301 - recall: 0.9720\n",
      "Epoch 79/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0299 - recall: 0.9720\n",
      "Epoch 80/1000\n",
      "213/213 [==============================] - 0s 190us/sample - loss: 0.0297 - recall: 0.9720\n",
      "Epoch 81/1000\n",
      "213/213 [==============================] - 0s 203us/sample - loss: 0.0295 - recall: 0.9720\n",
      "Epoch 82/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0294 - recall: 0.9720\n",
      "Epoch 83/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0292 - recall: 0.9720\n",
      "Epoch 84/1000\n",
      "213/213 [==============================] - 0s 115us/sample - loss: 0.0292 - recall: 0.9720\n",
      "Epoch 85/1000\n",
      "213/213 [==============================] - 0s 124us/sample - loss: 0.0290 - recall: 0.9720\n",
      "Epoch 86/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0290 - recall: 0.9720\n",
      "Epoch 87/1000\n",
      "213/213 [==============================] - 0s 221us/sample - loss: 0.0287 - recall: 0.9720\n",
      "Epoch 88/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0286 - recall: 0.9720\n",
      "Epoch 89/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0284 - recall: 0.9720\n",
      "Epoch 90/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0283 - recall: 0.9720\n",
      "Epoch 91/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0282 - recall: 0.9720\n",
      "Epoch 92/1000\n",
      "213/213 [==============================] - 0s 146us/sample - loss: 0.0281 - recall: 0.9720\n",
      "Epoch 93/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0280 - recall: 0.9720\n",
      "Epoch 94/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0279 - recall: 0.9720\n",
      "Epoch 95/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0277 - recall: 0.9720\n",
      "Epoch 96/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0277 - recall: 0.9720\n",
      "Epoch 97/1000\n",
      "213/213 [==============================] - 0s 210us/sample - loss: 0.0275 - recall: 0.9720\n",
      "Epoch 98/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0275 - recall: 0.9720\n",
      "Epoch 99/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0273 - recall: 0.9720\n",
      "Epoch 100/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0272 - recall: 0.9720\n",
      "Epoch 101/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0271 - recall: 0.9720\n",
      "Epoch 102/1000\n",
      "213/213 [==============================] - 0s 172us/sample - loss: 0.0270 - recall: 0.9720\n",
      "Epoch 103/1000\n",
      "213/213 [==============================] - 0s 166us/sample - loss: 0.0269 - recall: 0.9720\n",
      "Epoch 104/1000\n",
      "213/213 [==============================] - 0s 172us/sample - loss: 0.0268 - recall: 0.9720\n",
      "Epoch 105/1000\n",
      "213/213 [==============================] - 0s 184us/sample - loss: 0.0267 - recall: 0.9720\n",
      "Epoch 106/1000\n",
      "213/213 [==============================] - 0s 179us/sample - loss: 0.0265 - recall: 0.9720\n",
      "Epoch 107/1000\n",
      "213/213 [==============================] - 0s 217us/sample - loss: 0.0265 - recall: 0.9720\n",
      "Epoch 108/1000\n",
      "213/213 [==============================] - 0s 240us/sample - loss: 0.0265 - recall: 0.9720\n",
      "Epoch 109/1000\n",
      "213/213 [==============================] - 0s 180us/sample - loss: 0.0263 - recall: 0.9720\n",
      "Epoch 110/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0262 - recall: 0.9720\n",
      "Epoch 111/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0262 - recall: 0.9720\n",
      "Epoch 112/1000\n",
      "213/213 [==============================] - 0s 121us/sample - loss: 0.0261 - recall: 0.9720\n",
      "Epoch 113/1000\n",
      "213/213 [==============================] - 0s 123us/sample - loss: 0.0259 - recall: 0.9720\n",
      "Epoch 114/1000\n",
      "213/213 [==============================] - 0s 344us/sample - loss: 0.0259 - recall: 0.9720\n",
      "Epoch 115/1000\n",
      "213/213 [==============================] - 0s 180us/sample - loss: 0.0258 - recall: 0.9720\n",
      "Epoch 116/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0257 - recall: 0.9720\n",
      "Epoch 117/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0256 - recall: 0.9720\n",
      "Epoch 118/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0255 - recall: 0.9720\n",
      "Epoch 119/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0254 - recall: 0.9720\n",
      "Epoch 120/1000\n",
      "213/213 [==============================] - 0s 200us/sample - loss: 0.0254 - recall: 0.9720\n",
      "Epoch 121/1000\n",
      "213/213 [==============================] - 0s 159us/sample - loss: 0.0253 - recall: 0.9720\n",
      "Epoch 122/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0252 - recall: 0.9720\n",
      "Epoch 123/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0252 - recall: 0.9720\n",
      "Epoch 124/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0251 - recall: 0.9720\n",
      "Epoch 125/1000\n",
      "213/213 [==============================] - 0s 188us/sample - loss: 0.0250 - recall: 0.9720\n",
      "Epoch 126/1000\n",
      "213/213 [==============================] - 0s 189us/sample - loss: 0.0250 - recall: 0.9720\n",
      "Epoch 127/1000\n",
      "213/213 [==============================] - 0s 144us/sample - loss: 0.0248 - recall: 0.9720\n",
      "Epoch 128/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0248 - recall: 0.9720\n",
      "Epoch 129/1000\n",
      "213/213 [==============================] - 0s 175us/sample - loss: 0.0247 - recall: 0.9720\n",
      "Epoch 130/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0247 - recall: 0.9720\n",
      "Epoch 131/1000\n",
      "213/213 [==============================] - 0s 184us/sample - loss: 0.0245 - recall: 0.9720\n",
      "Epoch 132/1000\n",
      "213/213 [==============================] - 0s 253us/sample - loss: 0.0245 - recall: 0.9720\n",
      "Epoch 133/1000\n",
      "213/213 [==============================] - 0s 265us/sample - loss: 0.0244 - recall: 0.9720\n",
      "Epoch 134/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0244 - recall: 0.9720\n",
      "Epoch 135/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0243 - recall: 0.9720\n",
      "Epoch 136/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0243 - recall: 0.9720\n",
      "Epoch 137/1000\n",
      "213/213 [==============================] - 0s 252us/sample - loss: 0.0242 - recall: 0.9720\n",
      "Epoch 138/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0241 - recall: 0.9720\n",
      "Epoch 139/1000\n",
      "213/213 [==============================] - 0s 203us/sample - loss: 0.0240 - recall: 0.9720\n",
      "Epoch 140/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0241 - recall: 0.9720\n",
      "Epoch 141/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0239 - recall: 0.9720\n",
      "Epoch 142/1000\n",
      "213/213 [==============================] - 0s 166us/sample - loss: 0.0239 - recall: 0.9720\n",
      "Epoch 143/1000\n",
      "213/213 [==============================] - 0s 229us/sample - loss: 0.0238 - recall: 0.9720\n",
      "Epoch 144/1000\n",
      "213/213 [==============================] - 0s 438us/sample - loss: 0.0237 - recall: 0.9720\n",
      "Epoch 145/1000\n",
      "213/213 [==============================] - 0s 217us/sample - loss: 0.0237 - recall: 0.9720\n",
      "Epoch 146/1000\n",
      "213/213 [==============================] - 0s 113us/sample - loss: 0.0236 - recall: 0.9720\n",
      "Epoch 147/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0236 - recall: 0.9720\n",
      "Epoch 148/1000\n",
      "213/213 [==============================] - 0s 376us/sample - loss: 0.0235 - recall: 0.9720\n",
      "Epoch 149/1000\n",
      "213/213 [==============================] - 0s 171us/sample - loss: 0.0235 - recall: 0.9720\n",
      "Epoch 150/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0234 - recall: 0.9720\n",
      "Epoch 151/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0234 - recall: 0.9720\n",
      "Epoch 152/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0234 - recall: 0.9720\n",
      "Epoch 153/1000\n",
      "213/213 [==============================] - 0s 98us/sample - loss: 0.0233 - recall: 0.9720\n",
      "Epoch 154/1000\n",
      "213/213 [==============================] - 0s 162us/sample - loss: 0.0232 - recall: 0.9720\n",
      "Epoch 155/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 199us/sample - loss: 0.0232 - recall: 0.9720\n",
      "Epoch 156/1000\n",
      "213/213 [==============================] - 0s 306us/sample - loss: 0.0232 - recall: 0.9720\n",
      "Epoch 157/1000\n",
      "213/213 [==============================] - 0s 490us/sample - loss: 0.0230 - recall: 0.9720\n",
      "Epoch 158/1000\n",
      "213/213 [==============================] - 0s 173us/sample - loss: 0.0230 - recall: 0.9720\n",
      "Epoch 159/1000\n",
      "213/213 [==============================] - ETA: 0s - loss: 0.0054 - recall: 1.00 - 0s 119us/sample - loss: 0.0229 - recall: 0.9720\n",
      "Epoch 160/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0229 - recall: 0.9720\n",
      "Epoch 161/1000\n",
      "213/213 [==============================] - 0s 188us/sample - loss: 0.0229 - recall: 0.9720\n",
      "Epoch 162/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0228 - recall: 0.9720\n",
      "Epoch 163/1000\n",
      "213/213 [==============================] - 0s 99us/sample - loss: 0.0228 - recall: 0.9720\n",
      "Epoch 164/1000\n",
      "213/213 [==============================] - 0s 113us/sample - loss: 0.0227 - recall: 0.9720\n",
      "Epoch 165/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0227 - recall: 0.9720\n",
      "Epoch 166/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0226 - recall: 0.9720\n",
      "Epoch 167/1000\n",
      "213/213 [==============================] - 0s 117us/sample - loss: 0.0226 - recall: 0.9720\n",
      "Epoch 168/1000\n",
      "213/213 [==============================] - 0s 117us/sample - loss: 0.0225 - recall: 0.9720\n",
      "Epoch 169/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0225 - recall: 0.9720\n",
      "Epoch 170/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0225 - recall: 0.9720\n",
      "Epoch 171/1000\n",
      "213/213 [==============================] - 0s 130us/sample - loss: 0.0224 - recall: 0.9720\n",
      "Epoch 172/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0224 - recall: 0.9720\n",
      "Epoch 173/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0223 - recall: 0.9720\n",
      "Epoch 174/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0224 - recall: 0.9720\n",
      "Epoch 175/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0223 - recall: 0.9720\n",
      "Epoch 176/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0222 - recall: 0.9720\n",
      "Epoch 177/1000\n",
      "213/213 [==============================] - 0s 181us/sample - loss: 0.0222 - recall: 0.9720\n",
      "Epoch 178/1000\n",
      "213/213 [==============================] - 0s 853us/sample - loss: 0.0221 - recall: 0.9720\n",
      "Epoch 179/1000\n",
      "213/213 [==============================] - 0s 207us/sample - loss: 0.0221 - recall: 0.9720\n",
      "Epoch 180/1000\n",
      "213/213 [==============================] - 0s 224us/sample - loss: 0.0221 - recall: 0.9720\n",
      "Epoch 181/1000\n",
      "213/213 [==============================] - 0s 676us/sample - loss: 0.0221 - recall: 0.9720\n",
      "Epoch 182/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0220 - recall: 0.9720\n",
      "Epoch 183/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0220 - recall: 0.9720\n",
      "Epoch 184/1000\n",
      "213/213 [==============================] - 0s 96us/sample - loss: 0.0219 - recall: 0.9720\n",
      "Epoch 185/1000\n",
      "213/213 [==============================] - 0s 169us/sample - loss: 0.0219 - recall: 0.9720\n",
      "Epoch 186/1000\n",
      "213/213 [==============================] - 0s 110us/sample - loss: 0.0219 - recall: 0.9720\n",
      "Epoch 187/1000\n",
      "213/213 [==============================] - 0s 119us/sample - loss: 0.0218 - recall: 0.9720\n",
      "Epoch 188/1000\n",
      "213/213 [==============================] - 0s 290us/sample - loss: 0.0218 - recall: 0.9720\n",
      "Epoch 189/1000\n",
      "213/213 [==============================] - 0s 171us/sample - loss: 0.0217 - recall: 0.9720\n",
      "Epoch 190/1000\n",
      "213/213 [==============================] - 0s 185us/sample - loss: 0.0217 - recall: 0.9720\n",
      "Epoch 191/1000\n",
      "213/213 [==============================] - 0s 294us/sample - loss: 0.0218 - recall: 0.9720\n",
      "Epoch 192/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0216 - recall: 0.9720\n",
      "Epoch 193/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0216 - recall: 0.9720\n",
      "Epoch 194/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0216 - recall: 0.9720\n",
      "Epoch 195/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0216 - recall: 0.9720\n",
      "Epoch 196/1000\n",
      "213/213 [==============================] - 0s 262us/sample - loss: 0.0215 - recall: 0.9720\n",
      "Epoch 197/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0215 - recall: 0.9720\n",
      "Epoch 198/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0214 - recall: 0.9720\n",
      "Epoch 199/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0214 - recall: 0.9720\n",
      "Epoch 200/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0214 - recall: 0.9720\n",
      "Epoch 201/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0213 - recall: 0.9720\n",
      "Epoch 202/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0213 - recall: 0.9720\n",
      "Epoch 203/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0213 - recall: 0.9720\n",
      "Epoch 204/1000\n",
      "213/213 [==============================] - 0s 255us/sample - loss: 0.0213 - recall: 0.9720\n",
      "Epoch 205/1000\n",
      "213/213 [==============================] - 0s 297us/sample - loss: 0.0212 - recall: 0.9720\n",
      "Epoch 206/1000\n",
      "213/213 [==============================] - 0s 121us/sample - loss: 0.0212 - recall: 0.9720\n",
      "Epoch 207/1000\n",
      "213/213 [==============================] - 0s 130us/sample - loss: 0.0212 - recall: 0.9720\n",
      "Epoch 208/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0212 - recall: 0.9720\n",
      "Epoch 209/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0211 - recall: 0.9720\n",
      "Epoch 210/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0211 - recall: 0.9720\n",
      "Epoch 211/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0211 - recall: 0.9720\n",
      "Epoch 212/1000\n",
      "213/213 [==============================] - 0s 100us/sample - loss: 0.0211 - recall: 0.9720\n",
      "Epoch 213/1000\n",
      "213/213 [==============================] - 0s 93us/sample - loss: 0.0210 - recall: 0.9720\n",
      "Epoch 214/1000\n",
      "213/213 [==============================] - 0s 91us/sample - loss: 0.0210 - recall: 0.9720\n",
      "Epoch 215/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0209 - recall: 0.9720\n",
      "Epoch 216/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0210 - recall: 0.9720\n",
      "Epoch 217/1000\n",
      "213/213 [==============================] - 0s 90us/sample - loss: 0.0209 - recall: 0.9720\n",
      "Epoch 218/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0209 - recall: 0.9720\n",
      "Epoch 219/1000\n",
      "213/213 [==============================] - 0s 172us/sample - loss: 0.0209 - recall: 0.9720\n",
      "Epoch 220/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0208 - recall: 0.9720\n",
      "Epoch 221/1000\n",
      "213/213 [==============================] - 0s 113us/sample - loss: 0.0208 - recall: 0.9720\n",
      "Epoch 222/1000\n",
      "213/213 [==============================] - 0s 221us/sample - loss: 0.0208 - recall: 0.9720\n",
      "Epoch 223/1000\n",
      "213/213 [==============================] - 0s 144us/sample - loss: 0.0207 - recall: 0.9720\n",
      "Epoch 224/1000\n",
      "213/213 [==============================] - 0s 93us/sample - loss: 0.0207 - recall: 0.9720\n",
      "Epoch 225/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0207 - recall: 0.9720\n",
      "Epoch 226/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0207 - recall: 0.9720\n",
      "Epoch 227/1000\n",
      "213/213 [==============================] - 0s 182us/sample - loss: 0.0206 - recall: 0.9720\n",
      "Epoch 228/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0206 - recall: 0.9720\n",
      "Epoch 229/1000\n",
      "213/213 [==============================] - 0s 114us/sample - loss: 0.0207 - recall: 0.9720\n",
      "Epoch 230/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0206 - recall: 0.9720\n",
      "Epoch 231/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0206 - recall: 0.9720\n",
      "Epoch 232/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 113us/sample - loss: 0.0205 - recall: 0.9720\n",
      "Epoch 233/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0205 - recall: 0.9720\n",
      "Epoch 234/1000\n",
      "213/213 [==============================] - 0s 179us/sample - loss: 0.0205 - recall: 0.9720\n",
      "Epoch 235/1000\n",
      "213/213 [==============================] - 0s 144us/sample - loss: 0.0204 - recall: 0.9720\n",
      "Epoch 236/1000\n",
      "213/213 [==============================] - 0s 123us/sample - loss: 0.0204 - recall: 0.9720\n",
      "Epoch 237/1000\n",
      "213/213 [==============================] - 0s 108us/sample - loss: 0.0204 - recall: 0.9720\n",
      "Epoch 238/1000\n",
      "213/213 [==============================] - 0s 106us/sample - loss: 0.0204 - recall: 0.9720\n",
      "Epoch 239/1000\n",
      "213/213 [==============================] - 0s 118us/sample - loss: 0.0204 - recall: 0.9720\n",
      "Epoch 240/1000\n",
      "213/213 [==============================] - 0s 117us/sample - loss: 0.0203 - recall: 0.9720\n",
      "Epoch 241/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0204 - recall: 0.9720\n",
      "Epoch 242/1000\n",
      "213/213 [==============================] - 0s 110us/sample - loss: 0.0203 - recall: 0.9720\n",
      "Epoch 243/1000\n",
      "213/213 [==============================] - 0s 159us/sample - loss: 0.0203 - recall: 0.9720\n",
      "Epoch 244/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0202 - recall: 0.9720\n",
      "Epoch 245/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0203 - recall: 0.9720\n",
      "Epoch 246/1000\n",
      "213/213 [==============================] - 0s 130us/sample - loss: 0.0202 - recall: 0.9720\n",
      "Epoch 247/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0202 - recall: 0.9720\n",
      "Epoch 248/1000\n",
      "213/213 [==============================] - 0s 123us/sample - loss: 0.0202 - recall: 0.9720\n",
      "Epoch 249/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0201 - recall: 0.9720\n",
      "Epoch 250/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0201 - recall: 0.9720\n",
      "Epoch 251/1000\n",
      "213/213 [==============================] - 0s 106us/sample - loss: 0.0202 - recall: 0.9720\n",
      "Epoch 252/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0201 - recall: 0.9720\n",
      "Epoch 253/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0201 - recall: 0.9720\n",
      "Epoch 254/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0200 - recall: 0.9720\n",
      "Epoch 255/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0200 - recall: 0.9720\n",
      "Epoch 256/1000\n",
      "213/213 [==============================] - 0s 215us/sample - loss: 0.0200 - recall: 0.9720\n",
      "Epoch 257/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0200 - recall: 0.9720\n",
      "Epoch 258/1000\n",
      "213/213 [==============================] - 0s 118us/sample - loss: 0.0200 - recall: 0.9720\n",
      "Epoch 259/1000\n",
      "213/213 [==============================] - 0s 113us/sample - loss: 0.0199 - recall: 0.9720\n",
      "Epoch 260/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0199 - recall: 0.9720\n",
      "Epoch 261/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0199 - recall: 0.9720\n",
      "Epoch 262/1000\n",
      "213/213 [==============================] - 0s 133us/sample - loss: 0.0199 - recall: 0.9720\n",
      "Epoch 263/1000\n",
      "213/213 [==============================] - 0s 114us/sample - loss: 0.0199 - recall: 0.9720\n",
      "Epoch 264/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0199 - recall: 0.9720\n",
      "Epoch 265/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0199 - recall: 0.9720\n",
      "Epoch 266/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0198 - recall: 0.9720\n",
      "Epoch 267/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0198 - recall: 0.9720\n",
      "Epoch 268/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0198 - recall: 0.9720\n",
      "Epoch 269/1000\n",
      "213/213 [==============================] - 0s 172us/sample - loss: 0.0198 - recall: 0.9720\n",
      "Epoch 270/1000\n",
      "213/213 [==============================] - 0s 102us/sample - loss: 0.0198 - recall: 0.9720\n",
      "Epoch 271/1000\n",
      "213/213 [==============================] - 0s 109us/sample - loss: 0.0197 - recall: 0.9720\n",
      "Epoch 272/1000\n",
      "213/213 [==============================] - 0s 98us/sample - loss: 0.0197 - recall: 0.9720\n",
      "Epoch 273/1000\n",
      "213/213 [==============================] - 0s 103us/sample - loss: 0.0197 - recall: 0.9720\n",
      "Epoch 274/1000\n",
      "213/213 [==============================] - 0s 111us/sample - loss: 0.0197 - recall: 0.9720\n",
      "Epoch 275/1000\n",
      "213/213 [==============================] - 0s 105us/sample - loss: 0.0197 - recall: 0.9720\n",
      "Epoch 276/1000\n",
      "213/213 [==============================] - 0s 109us/sample - loss: 0.0197 - recall: 0.9720\n",
      "Epoch 277/1000\n",
      "213/213 [==============================] - 0s 127us/sample - loss: 0.0197 - recall: 0.9720\n",
      "Epoch 278/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0196 - recall: 0.9720\n",
      "Epoch 279/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0196 - recall: 0.9720\n",
      "Epoch 280/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0196 - recall: 0.9720\n",
      "Epoch 281/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0196 - recall: 0.9720\n",
      "Epoch 282/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0196 - recall: 0.9720\n",
      "Epoch 283/1000\n",
      "213/213 [==============================] - 0s 930us/sample - loss: 0.0196 - recall: 0.9720\n",
      "Epoch 284/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0195 - recall: 0.9720\n",
      "Epoch 285/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0195 - recall: 0.9720\n",
      "Epoch 286/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0195 - recall: 0.9720\n",
      "Epoch 287/1000\n",
      "213/213 [==============================] - ETA: 0s - loss: 0.0048 - recall: 1.00 - 0s 156us/sample - loss: 0.0195 - recall: 0.9720\n",
      "Epoch 288/1000\n",
      "213/213 [==============================] - 0s 541us/sample - loss: 0.0195 - recall: 0.9720\n",
      "Epoch 289/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0195 - recall: 0.9720\n",
      "Epoch 290/1000\n",
      "213/213 [==============================] - 0s 279us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 291/1000\n",
      "213/213 [==============================] - 0s 233us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 292/1000\n",
      "213/213 [==============================] - 0s 229us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 293/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 294/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 295/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 296/1000\n",
      "213/213 [==============================] - 0s 232us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 297/1000\n",
      "213/213 [==============================] - 0s 251us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 298/1000\n",
      "213/213 [==============================] - 0s 255us/sample - loss: 0.0194 - recall: 0.9720\n",
      "Epoch 299/1000\n",
      "213/213 [==============================] - 0s 123us/sample - loss: 0.0193 - recall: 0.9720\n",
      "Epoch 300/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0193 - recall: 0.9720\n",
      "Epoch 301/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 302/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0193 - recall: 0.9720\n",
      "Epoch 303/1000\n",
      "213/213 [==============================] - 0s 121us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 304/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 305/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 306/1000\n",
      "213/213 [==============================] - 0s 507us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 307/1000\n",
      "213/213 [==============================] - 0s 329us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 308/1000\n",
      "213/213 [==============================] - 0s 250us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 309/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 199us/sample - loss: 0.0191 - recall: 0.9720\n",
      "Epoch 310/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0191 - recall: 0.9720\n",
      "Epoch 311/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 312/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0192 - recall: 0.9720\n",
      "Epoch 313/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0191 - recall: 0.9720\n",
      "Epoch 314/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0191 - recall: 0.9720\n",
      "Epoch 315/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0191 - recall: 0.9720\n",
      "Epoch 316/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0191 - recall: 0.9720\n",
      "Epoch 317/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0191 - recall: 0.9720\n",
      "Epoch 318/1000\n",
      "213/213 [==============================] - 0s 146us/sample - loss: 0.0190 - recall: 0.9720\n",
      "Epoch 319/1000\n",
      "213/213 [==============================] - 0s 123us/sample - loss: 0.0190 - recall: 0.9720\n",
      "Epoch 320/1000\n",
      "213/213 [==============================] - 0s 114us/sample - loss: 0.0190 - recall: 0.9720\n",
      "Epoch 321/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0190 - recall: 0.9720\n",
      "Epoch 322/1000\n",
      "213/213 [==============================] - 0s 166us/sample - loss: 0.0190 - recall: 0.9720\n",
      "Epoch 323/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0190 - recall: 0.9720\n",
      "Epoch 324/1000\n",
      "213/213 [==============================] - 0s 203us/sample - loss: 0.0190 - recall: 0.9720\n",
      "Epoch 325/1000\n",
      "213/213 [==============================] - 0s 243us/sample - loss: 0.0189 - recall: 0.9720\n",
      "Epoch 326/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0190 - recall: 0.9720\n",
      "Epoch 327/1000\n",
      "213/213 [==============================] - 0s 189us/sample - loss: 0.0189 - recall: 0.9720\n",
      "Epoch 328/1000\n",
      "213/213 [==============================] - 0s 233us/sample - loss: 0.0189 - recall: 0.9720\n",
      "Epoch 329/1000\n",
      "213/213 [==============================] - 0s 199us/sample - loss: 0.0189 - recall: 0.9720\n",
      "Epoch 330/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0189 - recall: 0.9720\n",
      "Epoch 331/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0188 - recall: 0.9720\n",
      "Epoch 332/1000\n",
      "213/213 [==============================] - 0s 175us/sample - loss: 0.0189 - recall: 0.9720\n",
      "Epoch 333/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0188 - recall: 0.9720\n",
      "Epoch 334/1000\n",
      "213/213 [==============================] - 0s 229us/sample - loss: 0.0188 - recall: 0.9720\n",
      "Epoch 335/1000\n",
      "213/213 [==============================] - 0s 115us/sample - loss: 0.0188 - recall: 0.9720\n",
      "Epoch 336/1000\n",
      "213/213 [==============================] - 0s 175us/sample - loss: 0.0188 - recall: 0.9720\n",
      "Epoch 337/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0188 - recall: 0.9720\n",
      "Epoch 338/1000\n",
      "213/213 [==============================] - 0s 138us/sample - loss: 0.0188 - recall: 0.9720\n",
      "Epoch 339/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0188 - recall: 0.9720\n",
      "Epoch 340/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 341/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 342/1000\n",
      "213/213 [==============================] - 0s 115us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 343/1000\n",
      "213/213 [==============================] - 0s 95us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 344/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 345/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 346/1000\n",
      "213/213 [==============================] - 0s 349us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 347/1000\n",
      "213/213 [==============================] - 0s 307us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 348/1000\n",
      "213/213 [==============================] - 0s 316us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 349/1000\n",
      "213/213 [==============================] - 0s 144us/sample - loss: 0.0186 - recall: 0.9720\n",
      "Epoch 350/1000\n",
      "213/213 [==============================] - 0s 105us/sample - loss: 0.0187 - recall: 0.9720\n",
      "Epoch 351/1000\n",
      "213/213 [==============================] - 0s 95us/sample - loss: 0.0186 - recall: 0.9720\n",
      "Epoch 352/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0186 - recall: 0.9720\n",
      "Epoch 353/1000\n",
      "213/213 [==============================] - 0s 215us/sample - loss: 0.0186 - recall: 0.9720\n",
      "Epoch 354/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0186 - recall: 0.9720\n",
      "Epoch 355/1000\n",
      "213/213 [==============================] - 0s 186us/sample - loss: 0.0186 - recall: 0.9720\n",
      "Epoch 356/1000\n",
      "213/213 [==============================] - 0s 750us/sample - loss: 0.0186 - recall: 0.9720\n",
      "Epoch 357/1000\n",
      "213/213 [==============================] - 0s 210us/sample - loss: 0.0186 - recall: 0.9720\n",
      "Epoch 358/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 359/1000\n",
      "213/213 [==============================] - 0s 133us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 360/1000\n",
      "213/213 [==============================] - 0s 138us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 361/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 362/1000\n",
      "213/213 [==============================] - 0s 124us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 363/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 364/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 365/1000\n",
      "213/213 [==============================] - 0s 104us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 366/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 367/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 368/1000\n",
      "213/213 [==============================] - 0s 159us/sample - loss: 0.0185 - recall: 0.9720\n",
      "Epoch 369/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 370/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 371/1000\n",
      "213/213 [==============================] - 0s 226us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 372/1000\n",
      "213/213 [==============================] - 0s 335us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 373/1000\n",
      "213/213 [==============================] - 0s 233us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 374/1000\n",
      "213/213 [==============================] - 0s 342us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 375/1000\n",
      "213/213 [==============================] - 0s 366us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 376/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0184 - recall: 0.9720\n",
      "Epoch 377/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 378/1000\n",
      "213/213 [==============================] - 0s 250us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 379/1000\n",
      "213/213 [==============================] - 0s 248us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 380/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 381/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 382/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 383/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 384/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 385/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 386/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 171us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 387/1000\n",
      "213/213 [==============================] - 0s 313us/sample - loss: 0.0183 - recall: 0.9720\n",
      "Epoch 388/1000\n",
      "213/213 [==============================] - 0s 198us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 389/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 390/1000\n",
      "213/213 [==============================] - 0s 299us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 391/1000\n",
      "213/213 [==============================] - 0s 199us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 392/1000\n",
      "213/213 [==============================] - 0s 220us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 393/1000\n",
      "213/213 [==============================] - 0s 121us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 394/1000\n",
      "213/213 [==============================] - 0s 180us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 395/1000\n",
      "213/213 [==============================] - 0s 217us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 396/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 397/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 398/1000\n",
      "213/213 [==============================] - 0s 213us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 399/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0182 - recall: 0.9720\n",
      "Epoch 400/1000\n",
      "213/213 [==============================] - 0s 210us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 401/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 402/1000\n",
      "213/213 [==============================] - 0s 119us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 403/1000\n",
      "213/213 [==============================] - 0s 144us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 404/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 405/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 406/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 407/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 408/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0181 - recall: 0.9720\n",
      "Epoch 409/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 410/1000\n",
      "213/213 [==============================] - 0s 104us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 411/1000\n",
      "213/213 [==============================] - 0s 104us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 412/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 413/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 414/1000\n",
      "213/213 [==============================] - 0s 183us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 415/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 416/1000\n",
      "213/213 [==============================] - 0s 118us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 417/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 418/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 419/1000\n",
      "213/213 [==============================] - 0s 220us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 420/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 421/1000\n",
      "213/213 [==============================] - 0s 176us/sample - loss: 0.0180 - recall: 0.9720\n",
      "Epoch 422/1000\n",
      "213/213 [==============================] - 0s 118us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 423/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 424/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 425/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 426/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 427/1000\n",
      "213/213 [==============================] - 0s 85us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 428/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 429/1000\n",
      "213/213 [==============================] - 0s 212us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 430/1000\n",
      "213/213 [==============================] - 0s 169us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 431/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 432/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 433/1000\n",
      "213/213 [==============================] - 0s 87us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 434/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 435/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 436/1000\n",
      "213/213 [==============================] - 0s 199us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 437/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 438/1000\n",
      "213/213 [==============================] - 0s 181us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 439/1000\n",
      "213/213 [==============================] - 0s 336us/sample - loss: 0.0179 - recall: 0.9720\n",
      "Epoch 440/1000\n",
      "213/213 [==============================] - 0s 171us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 441/1000\n",
      "213/213 [==============================] - 0s 119us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 442/1000\n",
      "213/213 [==============================] - 0s 325us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 443/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 444/1000\n",
      "213/213 [==============================] - 0s 124us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 445/1000\n",
      "213/213 [==============================] - 0s 270us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 446/1000\n",
      "213/213 [==============================] - 0s 192us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 447/1000\n",
      "213/213 [==============================] - 0s 191us/sample - loss: 0.0178 - recall: 0.9720\n",
      "Epoch 448/1000\n",
      "213/213 [==============================] - 0s 208us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 449/1000\n",
      "213/213 [==============================] - 0s 200us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 450/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 451/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 452/1000\n",
      "213/213 [==============================] - 0s 202us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 453/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 454/1000\n",
      "213/213 [==============================] - 0s 348us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 455/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 456/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 457/1000\n",
      "213/213 [==============================] - 0s 205us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 458/1000\n",
      "213/213 [==============================] - 0s 166us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 459/1000\n",
      "213/213 [==============================] - 0s 232us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 460/1000\n",
      "213/213 [==============================] - 0s 179us/sample - loss: 0.0177 - recall: 0.9720\n",
      "Epoch 461/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 462/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 463/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 464/1000\n",
      "213/213 [==============================] - 0s 282us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 465/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 466/1000\n",
      "213/213 [==============================] - 0s 91us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 467/1000\n",
      "213/213 [==============================] - 0s 96us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 468/1000\n",
      "213/213 [==============================] - 0s 87us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 469/1000\n",
      "213/213 [==============================] - 0s 85us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 470/1000\n",
      "213/213 [==============================] - 0s 99us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 471/1000\n",
      "213/213 [==============================] - 0s 86us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 472/1000\n",
      "213/213 [==============================] - 0s 94us/sample - loss: 0.0176 - recall: 0.9720\n",
      "Epoch 473/1000\n",
      "213/213 [==============================] - 0s 91us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 474/1000\n",
      "213/213 [==============================] - 0s 104us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 475/1000\n",
      "213/213 [==============================] - 0s 76us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 476/1000\n",
      "213/213 [==============================] - 0s 105us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 477/1000\n",
      "213/213 [==============================] - 0s 77us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 478/1000\n",
      "213/213 [==============================] - 0s 80us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 479/1000\n",
      "213/213 [==============================] - 0s 88us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 480/1000\n",
      "213/213 [==============================] - 0s 90us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 481/1000\n",
      "213/213 [==============================] - 0s 203us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 482/1000\n",
      "213/213 [==============================] - 0s 210us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 483/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 484/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 485/1000\n",
      "213/213 [==============================] - 0s 576us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 486/1000\n",
      "213/213 [==============================] - 0s 172us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 487/1000\n",
      "213/213 [==============================] - 0s 218us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 488/1000\n",
      "213/213 [==============================] - 0s 176us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 489/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 490/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 491/1000\n",
      "213/213 [==============================] - 0s 244us/sample - loss: 0.0175 - recall: 0.9720\n",
      "Epoch 492/1000\n",
      "213/213 [==============================] - 0s 162us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 493/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 494/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 495/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 496/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 497/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 498/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 499/1000\n",
      "213/213 [==============================] - 0s 110us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 500/1000\n",
      "213/213 [==============================] - 0s 186us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 501/1000\n",
      "213/213 [==============================] - 0s 449us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 502/1000\n",
      "213/213 [==============================] - 0s 244us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 503/1000\n",
      "213/213 [==============================] - ETA: 0s - loss: 0.0220 - recall: 0.96 - 0s 351us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 504/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 505/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0174 - recall: 0.9720\n",
      "Epoch 506/1000\n",
      "213/213 [==============================] - 0s 169us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 507/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 508/1000\n",
      "213/213 [==============================] - 0s 146us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 509/1000\n",
      "213/213 [==============================] - 0s 101us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 510/1000\n",
      "213/213 [==============================] - 0s 169us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 511/1000\n",
      "213/213 [==============================] - 0s 117us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 512/1000\n",
      "213/213 [==============================] - 0s 89us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 513/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 514/1000\n",
      "213/213 [==============================] - 0s 110us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 515/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 516/1000\n",
      "213/213 [==============================] - 0s 121us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 517/1000\n",
      "213/213 [==============================] - 0s 215us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 518/1000\n",
      "213/213 [==============================] - 0s 250us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 519/1000\n",
      "213/213 [==============================] - 0s 573us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 520/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 521/1000\n",
      "213/213 [==============================] - 0s 402us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 522/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0173 - recall: 0.9720\n",
      "Epoch 523/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 524/1000\n",
      "213/213 [==============================] - 0s 220us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 525/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 526/1000\n",
      "213/213 [==============================] - 0s 138us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 527/1000\n",
      "213/213 [==============================] - 0s 127us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 528/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 529/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 530/1000\n",
      "213/213 [==============================] - 0s 263us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 531/1000\n",
      "213/213 [==============================] - 0s 144us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 532/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 533/1000\n",
      "213/213 [==============================] - 0s 155us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 534/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 535/1000\n",
      "213/213 [==============================] - 0s 102us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 536/1000\n",
      "213/213 [==============================] - 0s 169us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 537/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 538/1000\n",
      "213/213 [==============================] - 0s 205us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 539/1000\n",
      "213/213 [==============================] - 0s 229us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 540/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0172 - recall: 0.9720\n",
      "Epoch 541/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 542/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 543/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 544/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 545/1000\n",
      "213/213 [==============================] - 0s 221us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 546/1000\n",
      "213/213 [==============================] - 0s 179us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 547/1000\n",
      "213/213 [==============================] - 0s 189us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 548/1000\n",
      "213/213 [==============================] - 0s 119us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 549/1000\n",
      "213/213 [==============================] - 0s 92us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 550/1000\n",
      "213/213 [==============================] - 0s 120us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 551/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 552/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 553/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 554/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 555/1000\n",
      "213/213 [==============================] - 0s 173us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 556/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 557/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 558/1000\n",
      "213/213 [==============================] - 0s 199us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 559/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 560/1000\n",
      "213/213 [==============================] - 0s 248us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 561/1000\n",
      "213/213 [==============================] - 0s 530us/sample - loss: 0.0171 - recall: 0.9720\n",
      "Epoch 562/1000\n",
      "213/213 [==============================] - 0s 127us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 563/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 564/1000\n",
      "213/213 [==============================] - 0s 284us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 565/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 566/1000\n",
      "213/213 [==============================] - 0s 244us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 567/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 568/1000\n",
      "213/213 [==============================] - 0s 595us/sample - loss: 0.0170 - recall: 0.9720 - loss: 0.0031 - recall: 1.00\n",
      "Epoch 569/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 570/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 571/1000\n",
      "213/213 [==============================] - 0s 279us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 572/1000\n",
      "213/213 [==============================] - 0s 241us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 573/1000\n",
      "213/213 [==============================] - 0s 180us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 574/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 575/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 576/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 577/1000\n",
      "213/213 [==============================] - 0s 171us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 578/1000\n",
      "213/213 [==============================] - 0s 190us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 579/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 580/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0170 - recall: 0.9720\n",
      "Epoch 581/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 582/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 583/1000\n",
      "213/213 [==============================] - 0s 200us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 584/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 585/1000\n",
      "213/213 [==============================] - 0s 186us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 586/1000\n",
      "213/213 [==============================] - 0s 112us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 587/1000\n",
      "213/213 [==============================] - 0s 111us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 588/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 589/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 590/1000\n",
      "213/213 [==============================] - 0s 162us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 591/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 592/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 593/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 594/1000\n",
      "213/213 [==============================] - 0s 192us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 595/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 596/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 597/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 598/1000\n",
      "213/213 [==============================] - 0s 97us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 599/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 600/1000\n",
      "213/213 [==============================] - 0s 196us/sample - loss: 0.0169 - recall: 0.9720\n",
      "Epoch 601/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 602/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 603/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 604/1000\n",
      "213/213 [==============================] - 0s 124us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 605/1000\n",
      "213/213 [==============================] - 0s 108us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 606/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 607/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 608/1000\n",
      "213/213 [==============================] - 0s 175us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 609/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 610/1000\n",
      "213/213 [==============================] - 0s 234us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 611/1000\n",
      "213/213 [==============================] - 0s 214us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 612/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 613/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 614/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 615/1000\n",
      "213/213 [==============================] - 0s 181us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 616/1000\n",
      "213/213 [==============================] - 0s 195us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 617/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 175us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 618/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 619/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 620/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 621/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 622/1000\n",
      "213/213 [==============================] - 0s 162us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 623/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 624/1000\n",
      "213/213 [==============================] - 0s 234us/sample - loss: 0.0168 - recall: 0.9720\n",
      "Epoch 625/1000\n",
      "213/213 [==============================] - 0s 398us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 626/1000\n",
      "213/213 [==============================] - 0s 274us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 627/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 628/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 629/1000\n",
      "213/213 [==============================] - 0s 183us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 630/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 631/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 632/1000\n",
      "213/213 [==============================] - 0s 195us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 633/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 634/1000\n",
      "213/213 [==============================] - 0s 123us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 635/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 636/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 637/1000\n",
      "213/213 [==============================] - 0s 141us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 638/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 639/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 640/1000\n",
      "213/213 [==============================] - 0s 141us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 641/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0167 - recall: 0.9720\n",
      "Epoch 642/1000\n",
      "213/213 [==============================] - 0s 184us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 643/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 644/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 645/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 646/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 647/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 648/1000\n",
      "213/213 [==============================] - 0s 114us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 649/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 650/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 651/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 652/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 653/1000\n",
      "213/213 [==============================] - 0s 100us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 654/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 655/1000\n",
      "213/213 [==============================] - 0s 130us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 656/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 657/1000\n",
      "213/213 [==============================] - 0s 160us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 658/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 659/1000\n",
      "213/213 [==============================] - 0s 204us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 660/1000\n",
      "213/213 [==============================] - 0s 234us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 661/1000\n",
      "213/213 [==============================] - 0s 109us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 662/1000\n",
      "213/213 [==============================] - 0s 141us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 663/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 664/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 665/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 666/1000\n",
      "213/213 [==============================] - 0s 141us/sample - loss: 0.0166 - recall: 0.9720\n",
      "Epoch 667/1000\n",
      "213/213 [==============================] - 0s 558us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 668/1000\n",
      "213/213 [==============================] - 0s 244us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 669/1000\n",
      "213/213 [==============================] - 0s 188us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 670/1000\n",
      "213/213 [==============================] - 0s 210us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 671/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 672/1000\n",
      "213/213 [==============================] - 0s 95us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 673/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 674/1000\n",
      "213/213 [==============================] - 0s 110us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 675/1000\n",
      "213/213 [==============================] - 0s 114us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 676/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 677/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 678/1000\n",
      "213/213 [==============================] - 0s 295us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 679/1000\n",
      "213/213 [==============================] - 0s 181us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 680/1000\n",
      "213/213 [==============================] - 0s 103us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 681/1000\n",
      "213/213 [==============================] - 0s 155us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 682/1000\n",
      "213/213 [==============================] - 0s 121us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 683/1000\n",
      "213/213 [==============================] - 0s 155us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 684/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 685/1000\n",
      "213/213 [==============================] - 0s 179us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 686/1000\n",
      "213/213 [==============================] - 0s 193us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 687/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0165 - recall: 0.9720\n",
      "Epoch 688/1000\n",
      "213/213 [==============================] - 0s 103us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 689/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 690/1000\n",
      "213/213 [==============================] - 0s 115us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 691/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 692/1000\n",
      "213/213 [==============================] - 0s 101us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 693/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 694/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 695/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 696/1000\n",
      "213/213 [==============================] - 0s 103us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 697/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 698/1000\n",
      "213/213 [==============================] - 0s 112us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 699/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 700/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 701/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 702/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 703/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 704/1000\n",
      "213/213 [==============================] - 0s 127us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 705/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 706/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 707/1000\n",
      "213/213 [==============================] - 0s 166us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 708/1000\n",
      "213/213 [==============================] - 0s 189us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 709/1000\n",
      "213/213 [==============================] - 0s 433us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 710/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 711/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 712/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 713/1000\n",
      "213/213 [==============================] - 0s 104us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 714/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 715/1000\n",
      "213/213 [==============================] - 0s 118us/sample - loss: 0.0164 - recall: 0.9720\n",
      "Epoch 716/1000\n",
      "213/213 [==============================] - 0s 109us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 717/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 718/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 719/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 720/1000\n",
      "213/213 [==============================] - 0s 560us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 721/1000\n",
      "213/213 [==============================] - 0s 267us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 722/1000\n",
      "213/213 [==============================] - 0s 185us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 723/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 724/1000\n",
      "213/213 [==============================] - 0s 404us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 725/1000\n",
      "213/213 [==============================] - 0s 192us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 726/1000\n",
      "213/213 [==============================] - 0s 186us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 727/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 728/1000\n",
      "213/213 [==============================] - 0s 190us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 729/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 730/1000\n",
      "213/213 [==============================] - 0s 124us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 731/1000\n",
      "213/213 [==============================] - 0s 121us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 732/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 733/1000\n",
      "213/213 [==============================] - 0s 120us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 734/1000\n",
      "213/213 [==============================] - 0s 146us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 735/1000\n",
      "213/213 [==============================] - 0s 110us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 736/1000\n",
      "213/213 [==============================] - 0s 130us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 737/1000\n",
      "213/213 [==============================] - 0s 114us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 738/1000\n",
      "213/213 [==============================] - 0s 109us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 739/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 740/1000\n",
      "213/213 [==============================] - 0s 135us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 741/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 742/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0163 - recall: 0.9720\n",
      "Epoch 743/1000\n",
      "213/213 [==============================] - 0s 146us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 744/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 745/1000\n",
      "213/213 [==============================] - 0s 134us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 746/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 747/1000\n",
      "213/213 [==============================] - 0s 120us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 748/1000\n",
      "213/213 [==============================] - 0s 98us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 749/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 750/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 751/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 752/1000\n",
      "213/213 [==============================] - 0s 88us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 753/1000\n",
      "213/213 [==============================] - 0s 106us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 754/1000\n",
      "213/213 [==============================] - 0s 109us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 755/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 756/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 757/1000\n",
      "213/213 [==============================] - 0s 126us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 758/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 759/1000\n",
      "213/213 [==============================] - 0s 162us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 760/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 761/1000\n",
      "213/213 [==============================] - 0s 179us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 762/1000\n",
      "213/213 [==============================] - 0s 199us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 763/1000\n",
      "213/213 [==============================] - 0s 103us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 764/1000\n",
      "213/213 [==============================] - 0s 188us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 765/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 766/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 767/1000\n",
      "213/213 [==============================] - 0s 182us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 768/1000\n",
      "213/213 [==============================] - 0s 194us/sample - loss: 0.0162 - recall: 0.9720\n",
      "Epoch 769/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 770/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 771/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 97us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 772/1000\n",
      "213/213 [==============================] - 0s 138us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 773/1000\n",
      "213/213 [==============================] - 0s 164us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 774/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 775/1000\n",
      "213/213 [==============================] - 0s 185us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 776/1000\n",
      "213/213 [==============================] - 0s 95us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 777/1000\n",
      "213/213 [==============================] - 0s 123us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 778/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 779/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 780/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 781/1000\n",
      "213/213 [==============================] - 0s 121us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 782/1000\n",
      "213/213 [==============================] - 0s 113us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 783/1000\n",
      "213/213 [==============================] - 0s 115us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 784/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 785/1000\n",
      "213/213 [==============================] - 0s 103us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 786/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 787/1000\n",
      "213/213 [==============================] - 0s 113us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 788/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 789/1000\n",
      "213/213 [==============================] - 0s 120us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 790/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 791/1000\n",
      "213/213 [==============================] - 0s 155us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 792/1000\n",
      "213/213 [==============================] - 0s 141us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 793/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 794/1000\n",
      "213/213 [==============================] - 0s 118us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 795/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 796/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0161 - recall: 0.9720\n",
      "Epoch 797/1000\n",
      "213/213 [==============================] - 0s 127us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 798/1000\n",
      "213/213 [==============================] - 0s 137us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 799/1000\n",
      "213/213 [==============================] - 0s 133us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 800/1000\n",
      "213/213 [==============================] - 0s 202us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 801/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 802/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 803/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 804/1000\n",
      "213/213 [==============================] - 0s 187us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 805/1000\n",
      "213/213 [==============================] - 0s 106us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 806/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 807/1000\n",
      "213/213 [==============================] - 0s 112us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 808/1000\n",
      "213/213 [==============================] - 0s 173us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 809/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 810/1000\n",
      "213/213 [==============================] - 0s 173us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 811/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 812/1000\n",
      "213/213 [==============================] - 0s 172us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 813/1000\n",
      "213/213 [==============================] - 0s 104us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 814/1000\n",
      "213/213 [==============================] - 0s 93us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 815/1000\n",
      "213/213 [==============================] - 0s 97us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 816/1000\n",
      "213/213 [==============================] - 0s 185us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 817/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 818/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 819/1000\n",
      "213/213 [==============================] - 0s 132us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 820/1000\n",
      "213/213 [==============================] - 0s 112us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 821/1000\n",
      "213/213 [==============================] - 0s 124us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 822/1000\n",
      "213/213 [==============================] - 0s 192us/sample - loss: 0.0160 - recall: 0.9720\n",
      "Epoch 823/1000\n",
      "213/213 [==============================] - 0s 110us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 824/1000\n",
      "213/213 [==============================] - 0s 207us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 825/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 826/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 827/1000\n",
      "213/213 [==============================] - 0s 146us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 828/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 829/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 830/1000\n",
      "213/213 [==============================] - 0s 176us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 831/1000\n",
      "213/213 [==============================] - 0s 117us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 832/1000\n",
      "213/213 [==============================] - 0s 386us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 833/1000\n",
      "213/213 [==============================] - 0s 254us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 834/1000\n",
      "213/213 [==============================] - 0s 595us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 835/1000\n",
      "213/213 [==============================] - 0s 105us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 836/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 837/1000\n",
      "213/213 [==============================] - 0s 225us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 838/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 839/1000\n",
      "213/213 [==============================] - 0s 243us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 840/1000\n",
      "213/213 [==============================] - 0s 166us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 841/1000\n",
      "213/213 [==============================] - 0s 196us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 842/1000\n",
      "213/213 [==============================] - 0s 210us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 843/1000\n",
      "213/213 [==============================] - 0s 229us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 844/1000\n",
      "213/213 [==============================] - 0s 216us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 845/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 846/1000\n",
      "213/213 [==============================] - 0s 227us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 847/1000\n",
      "213/213 [==============================] - 0s 216us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 848/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 849/1000\n",
      "213/213 [==============================] - 0s 208us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 850/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 851/1000\n",
      "213/213 [==============================] - 0s 212us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 852/1000\n",
      "213/213 [==============================] - 0s 425us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 853/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 854/1000\n",
      "213/213 [==============================] - 0s 119us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 855/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0159 - recall: 0.9720\n",
      "Epoch 856/1000\n",
      "213/213 [==============================] - 0s 193us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 857/1000\n",
      "213/213 [==============================] - 0s 193us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 858/1000\n",
      "213/213 [==============================] - 0s 245us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 859/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 860/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 861/1000\n",
      "213/213 [==============================] - 0s 628us/sample - loss: 0.0158 - recall: 0.9720 - loss: 0.0255 - recall: 0.\n",
      "Epoch 862/1000\n",
      "213/213 [==============================] - 0s 183us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 863/1000\n",
      "213/213 [==============================] - 0s 467us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 864/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 865/1000\n",
      "213/213 [==============================] - 0s 192us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 866/1000\n",
      "213/213 [==============================] - 0s 167us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 867/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 868/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 869/1000\n",
      "213/213 [==============================] - 0s 173us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 870/1000\n",
      "213/213 [==============================] - 0s 175us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 871/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 872/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 873/1000\n",
      "213/213 [==============================] - 0s 169us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 874/1000\n",
      "213/213 [==============================] - 0s 148us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 875/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 876/1000\n",
      "213/213 [==============================] - 0s 116us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 877/1000\n",
      "213/213 [==============================] - 0s 213us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 878/1000\n",
      "213/213 [==============================] - 0s 162us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 879/1000\n",
      "213/213 [==============================] - 0s 255us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 880/1000\n",
      "213/213 [==============================] - 0s 163us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 881/1000\n",
      "213/213 [==============================] - 0s 226us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 882/1000\n",
      "213/213 [==============================] - 0s 176us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 883/1000\n",
      "213/213 [==============================] - 0s 109us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 884/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0158 - recall: 0.9720\n",
      "Epoch 885/1000\n",
      "213/213 [==============================] - 0s 106us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 886/1000\n",
      "213/213 [==============================] - 0s 468us/sample - loss: 0.0157 - recall: 0.9720 - loss: 0.0169 - recall: 0.96\n",
      "Epoch 887/1000\n",
      "213/213 [==============================] - 0s 316us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 888/1000\n",
      "213/213 [==============================] - 0s 169us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 889/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 890/1000\n",
      "213/213 [==============================] - 0s 187us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 891/1000\n",
      "213/213 [==============================] - 0s 159us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 892/1000\n",
      "213/213 [==============================] - 0s 187us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 893/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 894/1000\n",
      "213/213 [==============================] - 0s 313us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 895/1000\n",
      "213/213 [==============================] - 0s 141us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 896/1000\n",
      "213/213 [==============================] - 0s 180us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 897/1000\n",
      "213/213 [==============================] - 0s 136us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 898/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 899/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 900/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 901/1000\n",
      "213/213 [==============================] - 0s 153us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 902/1000\n",
      "213/213 [==============================] - 0s 223us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 903/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 904/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 905/1000\n",
      "213/213 [==============================] - 0s 184us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 906/1000\n",
      "213/213 [==============================] - 0s 123us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 907/1000\n",
      "213/213 [==============================] - 0s 204us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 908/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 909/1000\n",
      "213/213 [==============================] - 0s 242us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 910/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 911/1000\n",
      "213/213 [==============================] - ETA: 0s - loss: 6.5135e-04 - recall: 1.00 - 0s 178us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 912/1000\n",
      "213/213 [==============================] - 0s 154us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 913/1000\n",
      "213/213 [==============================] - 0s 143us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 914/1000\n",
      "213/213 [==============================] - 0s 481us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 915/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 916/1000\n",
      "213/213 [==============================] - 0s 170us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 917/1000\n",
      "213/213 [==============================] - 0s 94us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 918/1000\n",
      "213/213 [==============================] - 0s 101us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 919/1000\n",
      "213/213 [==============================] - 0s 104us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 920/1000\n",
      "213/213 [==============================] - 0s 129us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 921/1000\n",
      "213/213 [==============================] - 0s 145us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 922/1000\n",
      "213/213 [==============================] - 0s 193us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 923/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0157 - recall: 0.9720\n",
      "Epoch 924/1000\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 925/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 926/1000\n",
      "213/213 [==============================] - 0s 181us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 927/1000\n",
      "213/213 [==============================] - 0s 159us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 928/1000\n",
      "213/213 [==============================] - 0s 185us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 929/1000\n",
      "213/213 [==============================] - 0s 207us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 930/1000\n",
      "213/213 [==============================] - 0s 113us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 931/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 932/1000\n",
      "213/213 [==============================] - 0s 128us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 933/1000\n",
      "213/213 [==============================] - 0s 149us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 934/1000\n",
      "213/213 [==============================] - 0s 159us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 935/1000\n",
      "213/213 [==============================] - 0s 285us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 936/1000\n",
      "213/213 [==============================] - 0s 232us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 937/1000\n",
      "213/213 [==============================] - 0s 275us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 938/1000\n",
      "213/213 [==============================] - 0s 251us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 939/1000\n",
      "213/213 [==============================] - 0s 338us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 940/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 941/1000\n",
      "213/213 [==============================] - 0s 178us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 942/1000\n",
      "213/213 [==============================] - 0s 156us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 943/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 944/1000\n",
      "213/213 [==============================] - 0s 349us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 945/1000\n",
      "213/213 [==============================] - 0s 192us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 946/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 947/1000\n",
      "213/213 [==============================] - 0s 151us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 948/1000\n",
      "213/213 [==============================] - 0s 220us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 949/1000\n",
      "213/213 [==============================] - 0s 184us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 950/1000\n",
      "213/213 [==============================] - 0s 231us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 951/1000\n",
      "213/213 [==============================] - 0s 190us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 952/1000\n",
      "213/213 [==============================] - 0s 260us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 953/1000\n",
      "213/213 [==============================] - 0s 219us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 954/1000\n",
      "213/213 [==============================] - 0s 171us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 955/1000\n",
      "213/213 [==============================] - 0s 158us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 956/1000\n",
      "213/213 [==============================] - 0s 332us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 957/1000\n",
      "213/213 [==============================] - 0s 229us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 958/1000\n",
      "213/213 [==============================] - 0s 157us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 959/1000\n",
      "213/213 [==============================] - 0s 184us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 960/1000\n",
      "213/213 [==============================] - 0s 161us/sample - loss: 0.0156 - recall: 0.9720\n",
      "Epoch 961/1000\n",
      "213/213 [==============================] - 0s 254us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 962/1000\n",
      "213/213 [==============================] - 0s 190us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 963/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 964/1000\n",
      "213/213 [==============================] - 0s 146us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 965/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 966/1000\n",
      "213/213 [==============================] - 0s 177us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 967/1000\n",
      "213/213 [==============================] - 0s 312us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 968/1000\n",
      "213/213 [==============================] - 0s 290us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 969/1000\n",
      "213/213 [==============================] - 0s 176us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 970/1000\n",
      "213/213 [==============================] - 0s 186us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 971/1000\n",
      "213/213 [==============================] - 0s 231us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 972/1000\n",
      "213/213 [==============================] - 0s 176us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 973/1000\n",
      "213/213 [==============================] - 0s 227us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 974/1000\n",
      "213/213 [==============================] - 0s 220us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 975/1000\n",
      "213/213 [==============================] - 0s 189us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 976/1000\n",
      "213/213 [==============================] - 0s 202us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 977/1000\n",
      "213/213 [==============================] - 0s 165us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 978/1000\n",
      "213/213 [==============================] - 0s 224us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 979/1000\n",
      "213/213 [==============================] - 0s 260us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 980/1000\n",
      "213/213 [==============================] - 0s 144us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 981/1000\n",
      "213/213 [==============================] - 0s 180us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 982/1000\n",
      "213/213 [==============================] - 0s 961us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 983/1000\n",
      "213/213 [==============================] - 0s 152us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 984/1000\n",
      "213/213 [==============================] - 0s 142us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 985/1000\n",
      "213/213 [==============================] - 0s 125us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 986/1000\n",
      "213/213 [==============================] - 0s 175us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 987/1000\n",
      "213/213 [==============================] - 0s 379us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 988/1000\n",
      "213/213 [==============================] - 0s 179us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 989/1000\n",
      "213/213 [==============================] - 0s 174us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 990/1000\n",
      "213/213 [==============================] - 0s 168us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 991/1000\n",
      "213/213 [==============================] - 0s 147us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 992/1000\n",
      "213/213 [==============================] - 0s 131us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 993/1000\n",
      "213/213 [==============================] - 0s 155us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 994/1000\n",
      "213/213 [==============================] - 0s 734us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 995/1000\n",
      "213/213 [==============================] - 0s 122us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 996/1000\n",
      "213/213 [==============================] - 0s 139us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 997/1000\n",
      "213/213 [==============================] - 0s 320us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 998/1000\n",
      "213/213 [==============================] - 0s 150us/sample - loss: 0.0155 - recall: 0.9720\n",
      "Epoch 999/1000\n",
      "213/213 [==============================] - 0s 140us/sample - loss: 0.0154 - recall: 0.9720\n",
      "Epoch 1000/1000\n",
      "213/213 [==============================] - 0s 127us/sample - loss: 0.0154 - recall: 0.9720\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<tensorflow.python.keras.callbacks.History at 0x7fe1743c5a20>"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "siamese_model.fit( \n",
    "    [string1cv, string2cv],\n",
    "    1 - data['matched'].astype(float),\n",
    "    epochs=1000\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9802944806912361"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from scipy.spatial.distance import euclidean\n",
    "\n",
    "string_rep1 = string_featurization_model.predict(\n",
    "    ngram_featurizer.transform(data['string1'])\n",
    ")\n",
    "string_rep2 = string_featurization_model.predict(\n",
    "    ngram_featurizer.transform(data['string2'])\n",
    ")\n",
    "dists = np.zeros(shape=(len(data), 1))\n",
    "for i, (v1, v2) in enumerate(zip(string_rep1, string_rep2)):\n",
    "    dists[i] = euclidean(v1, v2)\n",
    "    \n",
    "roc_auc_score(data['matched'].astype(float), 1 - dists)\n",
    "0.9802944806912361\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Dj5u2rKxq5jc"
   },
   "outputs": [],
   "source": [
    "# some very basic plotting stuff\n",
    "# maybe useful for training\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib as mpl\n",
    "\n",
    "\n",
    "def plot_metrics(history, metrics=['loss', 'auc', 'precision', 'recall']):\n",
    "    for n, metric in enumerate(metrics):\n",
    "        name = metric.replace(\"_\",\" \").capitalize()\n",
    "        \n",
    "    mpl.rcParams['figure.figsize'] = (12, 10)\n",
    "    colors = plt.rcParams['axes.prop_cycle'].by_key()['color']\n",
    "    plt.subplot(2,2,n+1)\n",
    "    plt.plot(history.epoch,  history.history[metric], color=colors[0], label='Train')\n",
    "    plt.plot(history.epoch, history.history['val_'+metric],\n",
    "             color=colors[0], linestyle=\"--\", label='Val')\n",
    "    plt.xlabel('Epoch')\n",
    "    plt.ylabel(name)\n",
    "    if metric == 'loss':\n",
    "        plt.ylim([0, plt.ylim()[1]])\n",
    "    elif metric == 'auc':\n",
    "        plt.ylim([0.8,1])\n",
    "    else:\n",
    "        plt.ylim([0,1])\n",
    "\n",
    "    plt.legend()\n",
    "\n",
    "\n",
    "#plot_metrics(history, metrics=['recall'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 207
    },
    "colab_type": "code",
    "id": "fq2qugA76a9o",
    "outputId": "72845959-0ecd-41ba-9981-cccf87bab029"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: annoy in /Users/ben/anaconda3/lib/python3.6/site-packages (1.17.0)\r\n"
     ]
    }
   ],
   "source": [
    "!pip install annoy  # https://github.com/spotify/annoy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 425
    },
    "colab_type": "code",
    "id": "9ozdnuxFprNx",
    "outputId": "4c99ff05-d776-4cd1-ff67-cca7be7a52f1"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# given featurized strings, we can use nearest neighbor-search/classification\n",
    "# to decide very quickly which string matches and how well it matches.\n",
    "\n",
    "from annoy import AnnoyIndex\n",
    "\n",
    "index = AnnoyIndex(company_space.shape[1], 'euclidean')\n",
    "for i, company in enumerate(company_list):\n",
    "    emb = ngram_featurizer.transform([company]).toarray().flatten()\n",
    "    index.add_item(i, emb)\n",
    "    \n",
    "index.build(10)\n",
    "index.save('string_list.ann')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Blackrock',\n",
       " 'Credit Suisse',\n",
       " 'Goldman Sachs',\n",
       " 'Bank of America/Meryll Lynch',\n",
       " 'Morgan Stanley',\n",
       " 'LEK',\n",
       " 'JP Morgan',\n",
       " 'Nomura',\n",
       " 'BNP Paribas',\n",
       " 'WPP',\n",
       " 'Rothschild',\n",
       " 'Allianz']"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "company_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [],
   "source": [
    "#ngram_featurizer.get_feature_names()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 51
    },
    "colab_type": "code",
    "id": "3EmNdji7JI2Z",
    "outputId": "890cc39b-9f52-40a4-f16c-f635b2a38ee7"
   },
   "outputs": [],
   "source": [
    "v = ngram_featurizer.transform(['Allianz AG']).toarray().flatten()\n",
    "#ngram_featurizer.transform(['HSBC']).toarray()\n",
    "neighbours, distances = index.get_nns_by_vector(v, 3, search_k=-1, include_distances=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Allianz'"
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "company_list[neighbours[0]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "collapsed_sections": [],
   "name": "Finding the best fuzzy string matching",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
